/**
 * 表连接获取类
 * @author liaosh
 * @date 2022-10-22 23:08
 */
public class DataAccess {
    /**
     * 数据库类型，可优化成读取配置文件的配置
     */
    static String DBType = "MySQL";

    /**
     * 创建操作用户表的实例
     * @return
     */
    public static IUser createUserConnect() {
        // 反射方式获取实例
        String className = DBType + "User";
        Object object = null;
        try {
            Class<?> aClass = Class.forName(className);
            object = aClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (IUser) object;
    }

    /**
     * 创建操作部门表的实例
     * @return
     */
    public static IDepartment createDepartmentConnect() {
        String className = DBType + "Department";
        Object object = null;
        try {
            Class<?> aClass = Class.forName(className);
            object = aClass.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (IDepartment) object;
    }
}
